package com.szhn.common.exception;

import com.szhn.common.responsejson.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

public class GlobalException {
    @ControllerAdvice
    public class GlobalExceptionHandler {


        //处理Exception异常执行的方法
        @ExceptionHandler(Exception.class)
        @ResponseBody
        public R error(Exception e) {
            e.printStackTrace();
            return R.error().message("执行了全局异常处理");
        }
    }
}
